package fr.ece.ing4.si.MonteCarlo.Calculation.SingleThreadedVersion;


import java.util.concurrent.ExecutionException;

import fr.ece.ing4.si.MonteCarlo.Calculation.*;

public class MonteCarloSequentialSimulation extends MonteCarloSimulation
{
	/**
	 * Sequential calculation of the simulations.
	 */
	public double Simulation(String CallPutFlag, double S, double X,
		double T, double r, double b, double v, int nSteps, int nSimulations)
	{
		double Sum=0;	
		
		for(int i=1; i<nSimulations; i++)
		{
			Sum = Sum + MonteCarloSimulation.Calcul(CallPutFlag, nSteps, S, X, T, b, v);
		}
		
		//System.out.println("Sum: " + Math.exp(-r * T) * (Sum / nSimulations));
		return Math.exp(-r * T) * (Sum / nSimulations);
	}
	
	public static void main(final String[] args) throws InterruptedException, ExecutionException
	{
		new MonteCarloSequentialSimulation().timeAndComputeValue("c",40,50,0.5,0.06,0.1,0.45,168,100);
	}
}
